﻿/// <reference path="../common/list-base.js" />
!function () {
    var $ = fly;
    fly.base.UserList = $.Class({
        name: '用户',
        base: $.base.ListBase,
        buttons: ['add', 'edit', '<a id="btn-set-role" href="#">分配角色</a>',
        'remove',
         '<select id=combo-type ><option value=all >用户类型</option><option value=register >注册用户</option><option value=manager >管理员</option></select>',
         '<select id=combo-verify><option value=all >验证</option><option value=yes >邮箱已验证</option><option value=no >邮箱未验证</option></select> '
        ],

        createGrid: function () {
            this.$base.createGrid.call(this, {
                columns: [$.common.createSelection(), {
                    dataIndex: "LoginName",
                    header: "登录名"
                }, {
                    dataIndex: "NickName",
                    header: "名字"
                }, {
                    dataIndex: 'Sex',
                    header: '性别'
                }, {
                    dataIndex: "Email",
                    header: "邮箱"
                }, {
                    renderer: this.commandColRenderer()
                }]
            });
        },
        createMembers: function () {
            this.$base.createMembers.call(this);
            this.btnSetRole = $('#btn-set-role')
            this.comboType = $("#combo-type");
            this.comboVerify = $("#combo-verify");
        },
        initEvents: function () {
            var me = this;
            this.$base.initEvents.call(this);
            this.btnSetRole.click(function () {
                var ids = me.grid.getSelectionIds($.base.lang.noSelected.format("分配角色", "用户"))
                if (ids)
                    location.href = "form.htm?m=user&form=set-role&ids=" + ids.join(',')
                return false;
            });

            this.comboType.change(function () {
                me.store.params.UserType = this.value;
                me.pager.go(1, true);
            });

            this.comboVerify.change(function () {
                me.store.params.Verified = this.value;
                me.pager.go(1, true);
            });
        }
    });
    window.page = new fly.base.UserList()
    page.show();
} ()